//
//  TempChooseImageViewController.m
//  ZooNgonDoiOS
//
//  Created by Tran Minh Long on 9/9/12.
//  Copyright (c) 2012 Personal. All rights reserved.
//

#import "TempChooseImageViewController.h"

@interface TempChooseImageViewController ()

@end

@implementation TempChooseImageViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (id) initWithImage: (UIImage*) pickedImage {
    self = [self initWithNibName:nil bundle:nil];
    
    if (self) {
        _screenSize = self.view.bounds.size;
        
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 40, 320, 440)];
        [_imageView setImage:pickedImage];
        
        [self.view addSubview:_imageView];
        
        [_imageView release];
        
        [self initHeaderView];
    }
    
    return self;
}

- (void) initHeaderView {
    _vHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _screenSize.width, 48)];
    _vHeader.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:IMG_NAV_BACKGROUND]];
    
    _btnBack = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 48, 48)];
    [_btnBack setBackgroundImage:[UIImage imageNamed:IMG_BACK_NORMAL] forState:UIControlStateNormal];
    [_btnBack setBackgroundImage:[UIImage imageNamed:IMG_BACK_SELECTED] forState:UIControlStateHighlighted];
    [_btnBack addTarget:self action:@selector(backClicked) forControlEvents:UIControlEventTouchUpInside];
     
    [_vHeader addSubview:_btnBack];

    [self.view addSubview:_vHeader];
    
    [_btnBack release];
    [_vHeader release];
}

- (void) backClicked {
    [self dismissModalViewControllerAnimated:YES];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
